﻿using Anke.SHManage.IDAL;
using Anke.SHManage.Model;
using Anke.SHManage.MSSQLDAL;
using Anke.SHManage.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Anke.SHManage.Model.BasicEventInfo;
using System.Data;
using System.Data.SqlClient;

namespace Anke.SHManage.BLL
{
    public class AcceptEventBLL
    {
       private static readonly IAcceptEventDAL m_DAL = DataAccess.CreateAcceptEventDAL();
       private static readonly IAlarmEventDAL aeDAL = DataAccess.CreateAlarmEventDAL();

       //根据事件编码，受理序号获取受理基本信息
       public AcceptEventInfo GetAcceptEventInfoByCode(string code, int orderNum)
       {
            return  m_DAL.GetAcceptEventInfoByCode(code, orderNum);
       }
       #region 受理信息修改 2016-10-28
       public bool UpdateAccept(string EventCode, string AlarmReason, string PatientName, string Sex, string Age, string National, string Folk,
                string Judge,string LinkMan,string LinkTel,string Extension,string LocalAddr,string WaitAddr,string SendAddr,bool IsNeedLitter)
       {
           return m_DAL.UpdateAccept(EventCode, AlarmReason, PatientName, Sex, Age, National, Folk, Judge, LinkMan, LinkTel, Extension, LocalAddr, WaitAddr, SendAddr, IsNeedLitter);
       }
       public bool ModifyAccept(AcceptEventInfo info, string operatorCode)
       {
           bool result = false;
           string re = m_DAL.ModifyAccept(info, operatorCode);
           result = re.Length == 0 ? true : false;
           return result;
       }
       public List<ModifyRecordInfo> GetAcceptCrackInfos(int pageIndex, int pageSize, ref int rowCount, string EventCode)
       {
           return m_DAL.GetAcceptCrackInfos(pageIndex, pageSize, ref rowCount, EventCode);
       }
       #endregion

       //获取事件节点（事件编码和受理序号）目的：母页面用来分配tabs
       public AcceptEventInfo GetEventNode(string code)
       {
           return m_DAL.GetEventNode(code);
       }
       public AlarmEventInfo GetAlarmEventInfoByCode(string code)
       {
           return aeDAL.GetAlarmEventInfoByCode(code);

       }

       //获取电话录音 
       public object GetAlarmCalls(int page, int rows,ref int total, string eventCode, int OrderNumber)
       {
           return aeDAL.GetAlarmCalls(page, rows, ref total, eventCode, OrderNumber);
       }


       //任务和车辆明细 ，根据事件编码和受理序号，一次事件可多次受理，有多次任务。
       TaskAmbulanceDAL tadal = new TaskAmbulanceDAL();
       public TaskAmbulanceInfo GetTaskAmbulance(string taskCode)
       {
           return tadal.GetTaskAmbulance(taskCode);
       }

       //根据事件编码和受理序号获取 任务次数，任务编码（list<string>）
       public int GetTaskTimes(string eventCode, int orderNumber) 
       {
           return tadal.getTaskTime(eventCode, orderNumber);
       }
       public List<string> GetTaskCode(string eventCode, int orderNumber)
       {
           return tadal.getTaskCode(eventCode, orderNumber);
       }

       public List<string> getHadTaskOrder(string eventCode)
       {
           return tadal.getHadTaskOrder(eventCode);
       }
       public zTelRecordInfo GetTelRecordInfo(string TelRecordCode)
       {
           return tadal.GetTelRecordInfo(TelRecordCode);
       }

       public TaskGreenDate GetTaskGreenDate(string taskCode)
       {
           return tadal.GetTaskGreenDate(taskCode);
       }

       //事件信息修改 周志猛 2016-10-25
       private AlarmEventDAL dal = new AlarmEventDAL();
       #region 事件信息修改
       public bool UpdateEvent(string EventCode, string EvetnName, string Area, int EventSourceCode, int AccidentLevelCode, int AccidentTypeCode)
       {
           return aeDAL.UpdateEvent(EventCode, EvetnName, Area, EventSourceCode, AccidentLevelCode, AccidentTypeCode);
       }
       #endregion

       public bool ModifyEvent(AlarmEventInfo info, string operatorCode)
       {
           bool result = false;
           string re = aeDAL.ModifyEvent(info, operatorCode);
           result = re.Length == 0 ? true : false;
           return result;
       }

       public List<ModifyRecordInfo> GetEventCrackInfos(int pageIndex, int pageSize, ref int rowCount, string EventCode)
       {
           return aeDAL.GetEventCrackInfos(pageIndex, pageSize, ref rowCount, EventCode);
       }
       /// <summary>
       /// 根据工号查询人员信息
       /// </summary>
       /// <param name="workID"></param>
       /// <returns></returns>
       public PersonInfo GetPreson(string workID)
       {
           return dal.GetPreson(workID);
       }
    }
}
